package main

import (
	"fmt"
	"net/http"
	"path/filepath"
)

func serveFile(w http.ResponseWriter, req *http.Request) {

	filePath := "/Users/jibuzixin/Desktop/listen3 copy.go" // 替换为你的文件路径
	fileName := filepath.Base(filePath)
	fmt.Println("filename : ", fileName)
	w.Header().Set("Content-Disposition", "attachment; filename="+fileName)
	http.ServeFile(w, req, filePath)
}

func main() {
	http.HandleFunc("/", serveFile)

	fmt.Println("Server is running on :8080")
	err := http.ListenAndServe(":8080", nil)
	if err != nil {
		panic(err)
	}
}
